home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 09, No. 06 (1988-06)(MicroSPARC)(Side A).zip
/
Nibble Volume 09, No. 06 (1988-06)(MicroSPARC)(Side A).po
/
PRINTER.DUMP.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
8KB
|
259 lines
* Printer Dump
* by Robert Heath
* Copyright(c) 1988
* MicroSPARC, Inc. 1988
* Concord, MA 01742
*
* This program will add an external command to
* the ProDOS Basic Interpreter. This program
* is a 40/80 column screen dump. By entering
* 'DUMP', whatever is on the screen will be
* printed on your printer.
;
; Assembler: Apple ProDOS Editor-Assembler
***
* Program Equates
***
;
ORG $8000
CH EQU $24 ;Horz. cursor position
CV EQU $25 ;Vertical cursor position
BASL EQU $28 ;Address of start of line
CSWL EQU $36 ;Output hook
CSWH EQU $37
KSWL EQU $38 ;Input hook
KSWH EQU $39
LINE EQU $3C ;Variable for line number
A1L EQU $3C ;Temp monitor variable
A1H EQU $3D
A2L EQU $3E
A2H EQU $3F
EXTERNCMD EQU $BE07 ;External command handler
VPATH1 EQU $BE6C ;Pointer to command line
BIENTRY EQU $BE00 ;Entry point to BI
XTERNADDR EQU $BE50 ;Start of external program
XLEN EQU $BE52 ;Length of command
XCNUM EQU $BE53 ;Number of command
PBITS EQU $BE54 ;Parameters permitted
GETBUFR EQU $BEF5 ;Allocate buffers
MACHID EQU $BF98 ;Machine identification
KEYBOARD EQU $C000 ;Keyboard port
KBDSTROBE EQU $C010 ;Keyboard strobe
RD80VID EQU $C01F ;Test if in 80 column mode
* ; High bit set = 80 col
TXTPAGE1 EQU $C054 ;Access text page 1
TXTPAGE2 EQU $C055 ;Access text page 2
VTABZ EQU $FC24 ;Set BASL to correct line
HOME EQU $FC58 ;Clear the screen
COUT EQU $FDED ;Standard output routine
;
***
* Segement I
* Initialization
* This section installs the command
* in the BI and copies the next two
* sections to a free buffer.
***
;
LDA #$01 ;Allocate 1 page
JSR GETBUFR
BCS ERROR
STA A2H ;Save MSB for copy
STA XADDRH+1 ;Put MSB in section II
STA COMPARE+4 ;Save MSB in section II
LDA EXTERNCMD ;Save the current pointer
STA INVALID+2 ; in section II to link the
LDA EXTERNCMD+1 ; external commands
STA INVALID+3
LDA A2H ;Install our command
STA EXTERNCMD+1
LDA #$00
STA EXTERNCMD
STA A2L ;Set LSB for copy
LDA #<START ;Get the start of program
STA A1H ; and save for copy
LDA #>START
STA A1L
LDY #$00
COPY LDA (A1L),Y ;Get a byte of the program
STA (A2L),Y ; and put it in the buffer
INY
BNE COPY ;Loop until we are done
QUIT.X RTS
;
***
* Error Routine
***
;
ERROR LDX #$00 ;Print the error message
ERROR.1 LDA TXT.ERROR,X
BEQ ERROR.X
JSR COUT
INX
BNE ERROR.1
ERROR.X PLA ;Cancel return
PLA
JMP BIENTRY ;Enter the BI
;
MSB ON
TXT.ERROR DFB $8D,$8D,$87
ASC 'NO ROOM FOR THIS COMMAND.'
DFB $8D,$8D,$00
;
;
DS $8200-* ;Install padding
;
***
* Main Program
* This segement is installed in the
* buffer obtain by FREEBUFF.
* Note: This segement must be page alligned
***
;
DO >*
FAIL 1,Main segement not page alligned.
FIN
;
***
* Segement II
* Command Handler
* This section determines is 'DUMP'
* was entered. If it was, then it
* tells the BI to execute segement III.
* Otherwise, it jumps to the next
* command handler.
***
;
START CLD ;Identify this as a command
LDA VPATH1 ;Point to the command
STA A1L
LDA VPATH1+1
STA A1H
LDY #$04
COMPARE LDA (A1L),Y
CMP TXT.DUMP-1,Y
BNE INVALID
DEY
BNE COMPARE
LDA #$00 ;No parameters needed
STA PBITS
STA PBITS+1
STA XCNUM ;This is an external command
LDA #$03 ;Length of command - 1
STA XLEN
LDA #>MAIN ;Point to segement III
STA XTERNADDR
XADDRH LDA #$00 ;00 changed by segement I
STA XTERNADDR+1
CLC
RTS
INVALID SEC ;It's not us, pass to the
JMP $0000 ; next command handler
;
***
* Segement III
* Dump Routine
* This section does the printing
* of the screen
***
;
MAIN EQU *
LDA CSWL ;Save the important values
PHA
LDA CSWH
PHA
LDA KSWL
PHA
LDA KSWH
PHA
LDA CH
PHA
LDA CV
PHA
LDX #$FF ;Initialize 80 col flag
LDA MACHID ;Check to see if a 80 col
AND #$02 ; card is installed
BEQ MAIN40 ;No,must be in 40 col mode
BIT RD80VID ;In 80 col mode?
BPL MAIN40 ;No, in 40 col mode
LDX #$00 ;Yes,set flag for 80 col
MAIN40 EQU *
TXA ;Transfer flag to stack
PHA ; 0=80 Col $FF=40 Col
FIN
LDA #PRINTER ;Set output hook 2 printer
STA CSWH
LDA #$00
STA CSWL
TAX ;Print the init. string
INIT LDA STRING,X ;Get a character
BEQ INITX ;Exit if zero
JSR COUT ;Print the character
INX
BNE INIT ;Always branch
INITX LDA #$FF
STA LINE
PRLINE INC LINE ;Move to the next line
LDA LINE
STA CV
JSR VTABZ ;Set BASL to point to line
LDY #$00 ;Initialize to column 1
LOOP LDA KEYBOARD ;See if ESC was pressed
CMP #$9B
BEQ EXIT ;Yes, stop printing here
PLA ;In 40 col mode?
PHA
BNE COL40 ;Yes, forget page 2
PHP ;Save interrupt status
SEI ;Turn off the interrupts
STA TXTPAGE2 ;Access text page 2
LDA (BASL),Y ;Get a char from page 2
STA TXTPAGE1 ;Access text page 1
PLP ;Restore interrupt status
JSR COUT ;Print the character
COL40 LDA (BASL),Y ;Get a char from page 1
JSR COUT ; and print it.
INY ;Go to the next column
CPY #$28 ;End of line?
BNE LOOP ;No, continue with line
LDA #$8D ;Yes, Print a RETURN
JSR COUT
* LDA #$0A
* JSR COUT
NOP ;Leave room for code that
NOP ; can print a line feed
NOP
NOP
NOP
LDA LINE
CMP #$17 ;End of the screen?
BNE PRLINE ;No, do the next line
EXIT PLA ;Clear flag from stack
PLA
STA CV
JSR VTABZ
PLA
STA CH
PLA
STA KSWH
PLA
STA KSWL
PLA
STA CSWH
PLA
STA CSWL
STA KBDSTROBE ;Clear the strobe
RTS ;We're done,let's exit
;
***
* PROGRAM VARIABLES
***
;
MSB ON
STRING DFB $8D,$8D,$89 ;Set line size to 81 col.
ASC '82N' ; and print blank lines
DFB $8D,$8D,$00 ;80 columns + C.R. + L.F.
PRINTER EQU $C1 ;MSB of printer addr.
MSB OFF
TXT.DUMP ASC 'DUMP'